import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import BlankMain from '@/layout/components/BlankMain'

export const constantRoutes = [
  {
    path: '/',
    isTableRoute: false,
    component: BlankMain,
    redirect: '/loading',
    hidden: true,
    meta: { title: 'LOADING', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'loading',
        name: 'LOADING',
        component: () => import('@/views/loading/index'),
        meta: { title: 'LOADING', icon: 'table' }
      }
    ]
  },

  {
    path: '*',
    redirect: '/',
    hidden: true,
    isTableRoute: false
  }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
